package com.leetcode.algorithm.y22.m07;

import com.leetcode.algorithm.common.TreeNode;

/**
 * 701. 二叉搜索树中的插入操作
 * 
 * https://leetcode.cn/problems/insert-into-a-binary-search-tree/
 * 
 * @author jie.deng
 *
 */
class Question0701Solution01 {

	public TreeNode insertIntoBST(TreeNode root, int val) {
		if (root == null) {
			return new TreeNode(val);
		}
		if (root.val > val) {
			root.left = insertIntoBST(root.left, val);
		} else {
			root.right = insertIntoBST(root.right, val);
		}
		return root;
	}

}